package com.btl.utils;

import java.io.InputStream;

import org.json.JSONArray;
import org.json.JSONObject;

import android.webkit.JsPromptResult;

import com.btl.bean.Person;

public class PraseResponse {

	public static String parseVerification(InputStream inStream)
			throws Exception {

		byte[] data = StreamTools.getByteArrayData(inStream);
		String jsonstr = new String(data);
		JSONArray jsonArray = new JSONArray(jsonstr);
		JSONObject jsonObject = jsonArray.getJSONObject(0);
		String result = jsonObject.getString("msg");

		return result;
	}

	public static Person parsePerson(InputStream inStream) throws Exception {
		byte[] data = StreamTools.getByteArrayData(inStream);
		String jsonstr = new String(data);
		JSONArray jsonArray = new JSONArray(jsonstr);
		JSONObject jsonObject = jsonArray.getJSONObject(0);

		Person p = new Person();
		p.setPid(jsonObject.getString("id"));
		p.setPphone(jsonObject.getString("phone"));
		p.setPnickname(jsonObject.getString("nickname"));
		p.setPpass(jsonObject.getString("pass"));
		p.setPintro(jsonObject.getString("intro"));
		p.setPavatar(jsonObject.getString("avatar"));
		p.setZhuangtai(jsonObject.getString("zhuangtai"));

		return p;
	}

}
